package com.bojin.studio.ubattery;

import java.util.ArrayList;
import java.util.List;

import com.bojin.studio.ubattery.advice.BrightnessAdvice;
import com.bojin.studio.ubattery.advice.DataAdvice;
import com.bojin.studio.ubattery.advice.ScreenAdvice;
import com.bojin.studio.ubattery.advice.SyncAdvice;
import com.bojin.studio.ubattery.advice.WifiAdvice;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

public class AdviceFragment extends Fragment{
	BrightnessAdvice brightnessAdvice;
	ScreenAdvice screenAdvice;
	WifiAdvice wifiAdvice;
	DataAdvice dataAdvice;
	SyncAdvice syncAdvice;
	public AdviceFragment()
	{	
		
	}
	
	public void updateAdvice(Context context, View view,List<adviceInfo> adviceInfo )
	{
		AdviceInfoAdapter adapter = new AdviceInfoAdapter(context,adviceInfo);		 
	    ListView adviceList = (ListView) view.findViewById(R.id.listView1);  
		adviceList.setAdapter(adapter);
	}
	
	  @Override
	  public View onCreateView(LayoutInflater inflater, ViewGroup container,
	            Bundle savedInstanceState) {
	    	 View view=inflater.inflate(R.layout.fragment_advice, container, false); 
	    	
	    	 
	    	 List<adviceInfo> adviceList = new ArrayList<adviceInfo>();
	    	 
			 adviceInfo advice=new adviceInfo();
			// advice.content="No Advice";
			 brightnessAdvice=new BrightnessAdvice(getActivity());
			 brightnessAdvice.detect(adviceList);
	    	 screenAdvice=new ScreenAdvice(getActivity());
	    	 //adviceList.add(advice);
	    	 screenAdvice.detect(adviceList);
			 //adviceList.add(advice);
	    	 wifiAdvice=new WifiAdvice(getActivity());
	    	 wifiAdvice.detect(adviceList);
	    	 dataAdvice=new DataAdvice(getActivity());
	    	 dataAdvice.detect(adviceList);
	    	 syncAdvice=new SyncAdvice(getActivity());
	    	 syncAdvice.detect(adviceList);
			 updateAdvice(view.getContext(), view,adviceList);
	    	return view; 
	  } 
	  
	  @Override
	    public void onResume(){
	    	super.onResume();
	    	
	    }
	    
	    @Override
	    public void onPause(){
	    	super.onPause();
	    	
	    }

}
